//json 转换为 字符串
function jts(k) {
	return $summer.jsonToStr(k);
}

//字符串  转为  json
function stj(k) {
	return $summer.strToJson(k);
}

//保存信息
function saveInfo(key, value) {
	summer.setStorage(key, value);
}

//获取信息
function getInfo(key) {
	return summer.getStorage(key);
}

function isExit() {
	UM.confirm({
		title : '友情提示：',
		text : '确定要退出吗?',
		btnText : ["取消", "确定"],
		overlay : true,
		ok : function() {
			//$this.css('backgroundColor', 'red');
			summer.closeWin();
		},
		cancle : function() {
			return ;
			//$this.css('backgroundColor', '#007aff');
		}
	});
	/*if (confirm("确定要退出吗?")) {
		summer.closeWin();
	}*/
}

document.addEventListener("backbutton", onBackKeyDown, false);
//监听返回键
var turn = 0;
function onBackKeyDown() {
	turn++;
	if (turn == 2) {
		clearInterval(intervalID);
		summer.exitApp()
	} else {
		summer.toast({
			"msg" : "再点击一次退出!"
		});
	}
	var intervalID = setInterval(function() {
		clearInterval(intervalID);
		turn = 0;
	}, 3000);
};

//获取当前日期
function getNowDate(){
	var date = new Date();
	var mon = date.getMonth() + 1;
	var day = date.getDate();
	var mydate = date.getFullYear() + "-" + (mon<10?"0"+mon:mon) + "-" +(day<10?"0"+day:day);
	//console.log(mydate);
	return mydate;
};
//获取当前时间（到秒）
function getNowDateTime(){
	var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + date.getHours() + seperator2 + date.getMinutes()
            + seperator2 + date.getSeconds();
    return currentdate;
};
